package com.me.springcloud.retrofit;

import java.util.concurrent.TimeUnit;

import io.reactivex.schedulers.Schedulers;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

public class LoginDemo {
	public static final String API_URL = "https://epay.test-cignacmb.com/ePay/uat1/";

	public static void main(String[] args) throws InterruptedException {
		Retrofit retrofit = new Retrofit.Builder().baseUrl(API_URL)//
				.addCallAdapterFactory(RxJava2CallAdapterFactory.create())//
				.addConverterFactory(GsonConverterFactory.create())//

				.build();

		LoginService loginService = retrofit.create(LoginService.class);

		loginService.getToken("1", "2")//
				.subscribeOn(Schedulers.io())
				.subscribe(t -> {
					System.out.println("myonNext:" + t.getCode() + "," + t.getMessage());
				});

//				.subscribeOn(Schedulers.io()).subscribe(new Subscriber<BaseEntity<String>>() {
//
//					@Override
//					public void onCompleted() {
//						System.out.println("onCompleted ");
//
//					}
//
//					@Override
//					public void onError(Throwable e) {
//						System.out.println("onError " + e);
//					}
//
//					@Override
//					public void onNext(BaseEntity<String> t) {
//						System.out.println("onNext " + t.getCode());
//					}
//
//				});

		TimeUnit.SECONDS.sleep(5);
	}
}
